package jmine.tec.web.servlet.cipher.impl;

import java.io.IOException;
import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jmine.tec.utils.Tuple;
import jmine.tec.utils.UnmodifiableTuple;
import jmine.tec.web.servlet.cipher.SecureCommunicationHandler;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Implementacao abstrata de {@link SecureCommunicationHandler} que implementa os metodos com stubs e fornece um {@link Log}
 * 
 * @author takeshi
 */
public abstract class AbstractSecureCommunicationHandler implements SecureCommunicationHandler, Serializable {

    private final Log logger = LogFactory.getLog(this.getClass());

    /**
     * {@inheritDoc}
     */
    public SecureCommunicationHandler nextStage(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException {
        return this;
    }

    /**
     * {@inheritDoc}
     */
    public boolean proceedRequest(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public Tuple<HttpServletRequest, HttpServletResponse> wrapRequestResponse(HttpServletRequest request, HttpServletResponse response)
            throws IOException {
        return UnmodifiableTuple.newTuple(request, response);
    }

    /**
     * @return the logger
     */
    protected final Log getLogger() {
        return logger;
    }

}
